package com.ssyt.yt1.day20;

public class Calculate {
	int money;
	int price;
	int bottle_exchange_beer;
	int cap_exchange_beer;

	public Calculate(int money, int price, int bottle_exchange_beer,
			int cap_exchange_beer) {
		super();
		this.money = money;
		this.price = price;
		this.bottle_exchange_beer = bottle_exchange_beer;
		this.cap_exchange_beer = cap_exchange_beer;
	}

	public void function() {
		int count = money / price;// 5
		int bottle = money / price;
		int cap = money / price;
		int i = 0;// 计算兑换次数
		while (cap >= cap_exchange_beer || bottle >= bottle_exchange_beer) {
			i++;
			int temp = 0;// 兑换到的啤酒
			temp += bottle / bottle_exchange_beer;// 2
			temp += cap / cap_exchange_beer;// 1
			count += temp;
			bottle = (bottle % bottle_exchange_beer) + temp;// 1 + 3
			cap = (cap % cap_exchange_beer) + temp;// 1 + 3
			System.out.println("第" + i + "次兑换共可以喝到：" + count + "瓶啤酒");
			System.out.println("喝完剩下空瓶子：" + bottle + "个");
			System.out.println("喝完剩下瓶盖：" + cap + "个");
			System.out.println("--------------------------");
		}

	}

	public static void main(String[] args) {
		new Calculate(10, 2, 2, 4).function();
	}
}
